package com.mall.user.services;

import com.mall.user.ILoginServicesss;
import com.mall.user.dal.entitys.Member;
import com.mall.user.dal.persistence.MemberMapper;
import com.mall.user.dto.LoginResponse;
import com.mall.user.utils.JwtTokenUtils;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Service
public class LoginServiceImpl implements ILoginServicesss {

    @Autowired
    MemberMapper memberMapper;

    @Override
    public LoginResponse login(String token) {
        LoginResponse loginResponse = new LoginResponse();
        JwtTokenUtils tokenUtils = JwtTokenUtils.builder().token(token).build();
        String userId = tokenUtils.freeJwt();
        Member member = memberMapper.selectByPrimaryKey(userId);
        if (member == null){
        }
        loginResponse.setUid(member.getId());
        loginResponse.setUsername(member.getUsername());
        loginResponse.setFile(member.getFile());
        return loginResponse;
    }

}
